//
//  SettingViewController.m
//  CreditHub
//
//  Created by chenglang on 2024/9/21.
//

#import "SettingViewController.h"
#import "PersonalCenterItemView.h"
#import "HomeRequest.h"
#import "BankPopupViewController.h"
#import "AccountCancellationVC.h"
#import "ExitPopUpViewController.h"

@interface SettingViewController ()
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UIImageView *imageTitle;
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutHeight;
@property (nonatomic , strong) NSMutableArray *arraySuchan;

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.ch_title = @"Settings";
    [self requestInfo];
    
}
- (void)requestInfo{
    for(int i = 0 ; i < 3;i++){
       
        PersonalCenterItemView *view = [[NSBundle mainBundle] loadNibNamed:@"PersonalCenterItemView" owner:self options:@{}].firstObject;
        view.button.tag = 2000+i;
        [view.button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        view.backgroundColor = colorWithHex(0xFFFDE2);
        [self.contentView addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
            make.height.offset(84);
            make.top.mas_equalTo(i*104+20);
        }];
        
        if(i == 0){
            view.imageViewIcon.image = [UIImage imageNamed:@"setting_verition"];
            view.labelTitle.text = @"Version";
            view.labelRightTitle.hidden = NO;
            view.imgViewArrow.hidden = YES;
            NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
            view.labelRightTitle.text = [NSString stringWithFormat:@"V%@",version];
        }else if(i==1){
            view.imageViewIcon.image = [UIImage imageNamed:@"setting_accoount"];
            view.labelTitle.text = @"Account cancellation";
        }else if(i==2){
            view.imageViewIcon.image = [UIImage imageNamed:@"setting_tuichu"];
            view.labelTitle.text = @"Exit";
        }
        
    }
    self.layoutHeight.constant =  3*104 +20;
}
- (void)click:(UIButton *)button{
    switch (button.tag-2000) {
        case 1:{
            AccountCancellationVC *vc = [[AccountCancellationVC alloc] init];
            [self.navigationController pushViewController:vc animated: YES];
        }
            break;
        case 2:{
            ExitPopUpViewController *vc = [[ExitPopUpViewController alloc] init];
            vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
            __weak typeof(self) weakSelf = self;
            vc.okBlock = ^{
                [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                [UserInfoModel logout];
            };
            [self presentViewController:vc animated:YES completion:^{
                
            }];
        }
            break;
            
        default:
            break;
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
